import ButtionRender1 from '@/components/aggridCellRenDerer/buttionRender1.vue'
import tagRender from '@/components/aggridCellRenDerer/tagRender.vue'
const tableColumns = [
  // {
  //   headerCheckboxSelection: true,
  //   checkboxSelection: true,
  //   width: 50,
  //   showDisabledCheckboxes: false,
  //   pinned: 'left',
  // },
  {
    headerName: '公司',
    field: 'companyName',
    width: 150,
  },
  {
    headerName: '仓库名称',
    field: 'warehouseName',
    width: 150,
  },
  {
    headerName: '库位',
    field: 'storageName',
    width: 150,
  },
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '流转卡号',
    field: 'circulatCard',
    width: 150,
  },
  {
    headerName: '客户订单号',
    field: 'customOrderCode',
    width: 150,
  },
  {
    headerName: '订单号',
    field: 'orderCode',
    width: 150,
  },
  {
    headerName: '布号',
    field: 'clothCode',
    width: 150,
  },
  {
    headerName: '品名',
    field: 'brandName',
    width: 150,
  },
  {
    headerName: '色号',
    field: 'colorCode',
    width: 150,
  },
  {
    headerName: '色称',
    field: 'colorName',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'horseNo',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '单价',
    field: 'price',
    width: 150,
  },
  {
    headerName: '金额',
    field: 'money',
    width: 150,
    valueGetter: (params: any) => {
      return parseFloat((params.data.weight * params.data.price).toFixed(2))
    }
  },
  {
    headerName: '布笼编号',
    field: 'shelveCode',
    width: 150,
  },
  {
    headerName: '出库单号',
    field: 'stockOutCode',
    width: 150,
  },
  {
    headerName: '开单日期',
    field: 'createTime',
    width: 150,
  },
  {
    headerName: '出库类型',
    field: 'stockOutTypeTypeName',
    width: 150,
  },
  {
    headerName: '开单人员',
    field: 'createName',
    width: 150,
  },
  {
    headerName: '备注',
    field: 'remark',
    width: 150,
  },
  {
    headerName: '审核状态',
    field: 'auditState',
    width: 150,
    cellRenderer: tagRender,
    cellRendererParams: {
      styleClass: (params: any) => {
        return params.auditState == 0
          ? 'warning'
          : params.auditState == 1
            ? 'success' : ''
      },
      text: (params: any) => {
        return params.auditState == 0
          ? '待审核'
          : params.auditState == 1
            ? '审核通过' : ''
      },
      eltagSize: 0,
    },
    filterParams: {
      valueFormatter: function (params: any) {
        return params.value == '0'
          ? '待审核'
          : params.value == '1'
            ? '审核通过' : ''
      },
    }
  },
  {
    headerName: '审核人',
    field: 'auditName',
    width: 150,
  },
  {
    headerName: '审核日期',
    field: 'auditTime',
    width: 150,
  },
  {
    headerName: '操作',
    field: 'action',
    width: 150,
    pinned: 'right',
    cellRenderer: ButtionRender1,
    cellRendererParams: (params: any) => {
      return {
        buttonList: [
          {
            type: params.data.auditState == 0 ? 'primary' : 'info',
            text: '修改',
            typeName: 'el-button',
            show: true,
            disabled: params.data.auditState == 0 ? false : true,
            Callback: (data: any) => {
              return {
                rowData: data,
                emitString: 'FinishedProductOutstock-edit'
              }
            },
          },
        ],
        eltagSize: 0,
      }
    }
  },
]
const tableColumns2 = [
  {
    headerCheckboxSelection: true,
    checkboxSelection: true,
    width: 50,
    showDisabledCheckboxes: false,
    pinned: 'left',
  },
  {
    headerName: '订单号',
    field: 'orderCode',
    width: 150,
  },
  {
    headerName: '客户订单号',
    field: 'customOrderCode',
    width: 150,
  },
  {
    headerName: '流转卡号',
    field: 'circulatCard',
    width: 150,
  },
  {
    headerName: '布号',
    field: 'clothCode',
    width: 150,
  },
  {
    headerName: '品名',
    field: 'brandName',
    width: 150,
  },
  {
    headerName: '色号',
    field: 'colorCode',
    width: 150,
  },
  {
    headerName: '色称',
    field: 'colorName',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'horseNo',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '布笼编号',
    field: 'shelveCode',
    width: 150,
  },
  {
    headerName: '库位',
    field: 'storageName',
    width: 150,
  },
  {
    headerName: '单价',
    field: 'price',
    width: 150,
    cellRenderer: {
      template: `<a-input-number v-if="show" v-model="rowData.price" :precision="2"  :min="0" :max="10000000" @change="change"/>`,
      setup(props: any) {
        const rowData = ref(props.params.data)
        const show = ref(props.params.node.rowPinned!='bottom')
        const change = (val) => {
          props.params.setValue(val)
        }
        return {
          rowData,
          change,
          show
        }
      }
    },
    valueSetter: (params: any) => {
      if (params.data.price != 0 && params.data.weight != 0) {
        params.data.amount = parseFloat((Number(params.data.price) * Number(params.data.weight)).toFixed(2))
        return true
      } else {
        params.data.amount = 0
        return true
      }
    }
  },
  {
    headerName: '金额',
    field: 'amount',
    width: 150,
  },
]
const tableColumns3 = [
  {
    headerCheckboxSelection: true,
    checkboxSelection: true,
    width: 50,
    showDisabledCheckboxes: false,
    pinned: 'left',
  },
  {
    headerName: '客户名称',
    field: 'customName',
    width: 150,
  },
  {
    headerName: '订单号',
    field: 'orderCode',
    width: 150,
  },
  {
    headerName: '客户订单号',
    field: 'customOrderCode',
    width: 150,
  },
  {
    headerName: '流转卡号',
    field: 'circulatCard',
    width: 150,
  },
  {
    headerName: '布号',
    field: 'clothCode',
    width: 150,
  },
  {
    headerName: '品名',
    field: 'brandName',
    width: 150,
  },
  {
    headerName: '色号',
    field: 'colorCode',
    width: 150,
  },
  {
    headerName: '色称',
    field: 'colorName',
    width: 150,
  },
  {
    headerName: '匹数',
    field: 'horseNo',
    width: 150,
  },
  {
    headerName: '重量',
    field: 'weight',
    width: 150,
  },
  {
    headerName: '布笼编号',
    field: 'shelveCode',
    width: 150,
  },
  {
    headerName: '库位',
    field: 'storageName',
    width: 150,
  },
]
export { tableColumns, tableColumns2, tableColumns3 } 
